#include<iostream>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        char a[15];
        char b[15];
        char c[15];
        cin >> a;
        cin >> b;
        cin >> c;
        int a1, b1;
        int a2, b2;
        int a3, b3;
        cin >> a1 >> b1;
        cin >> a2 >> b2;
        cin >> a3 >> b3;
        int len1 = b1 - a1 + 1;
        int len2 = b2 - a2 + 1;
        int len3 = b3 - a3 + 1;
        int len = len1 + len2 + len3;
        char* newone = new char[len];
        char* p1 = a + a1 - 1;
        char* p2 = b + a2 - 1;
        char* p3 = c + a3 - 1;
        for (int i = 0; i < len; i++)
        {
            if (i < len1)
            {
                newone[i] = p1[i];
            }
            else if (i >= len1 && i < len1 + len2)
            {
                newone[i] = p2[i - len1];
            }
            else
            {
                newone[i] = p3[i - len1 - len2];
            }
        }
        for (int i = 0; i < len; i++)
        {
            cout << newone[i];
        }
        cout << endl;
    }
    return 0;
}